//
//  InboxCellView.m
//  LStyle
//
//  Created by Obaid Abdul Maroof on 12/20/09.
//  Copyright 2009 Vrije University. All rights reserved.
//

#import "InboxCellView.h"


@implementation InboxCellView

- (id)initWithFrame:(CGRect)aRect reuseIdentifier:(NSString *)identifier{
	if (self = [super initWithFrame:aRect reuseIdentifier:identifier])
	{
		// turn off selection use
		self.selectionStyle = UITableViewCellSelectionStyleGray;
		
		CGSize size = aRect.size;
		
		size.width = (size.width/4); 
		CGRect tempRect = aRect;
		tempRect.size = size;
		
		UIImage *img = [UIImage imageNamed:@"inbox.png"];
		imgImage = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, tempRect.size.width, tempRect.size.height-5)];
		imgImage.image = img;
		
		lblSender = [[UILabel alloc] initWithFrame:CGRectMake(tempRect.size.width + 5, 5, aRect.size.width - tempRect.size.width - 40 , 25)];
		lblTime = [[UILabel alloc] initWithFrame:CGRectMake(aRect.size.width -40, 5, 30 , 20)];
		lblSubject = [[ UILabel alloc] initWithFrame:CGRectMake(tempRect.size.width + 5, 45, aRect.size.width - tempRect.size.width - 10, 30)];
		lblContent = [[ UILabel alloc] initWithFrame:CGRectMake(tempRect.size.width + 5, 75, aRect.size.width - tempRect.size.width - 10, 35)];
		
		lblContent.lineBreakMode = UILineBreakModeWordWrap;
		lblContent.numberOfLines = 0;
		
		
		lblSender.text = @"MOLEN ANTOLIN FLORES";
		lblTime.text = @"08:53";
		lblSubject.text = @"YOUR WEEKLY NEWSLETTER";
		lblContent.text = @"Here is the weekly newletter you subscribed for. Please feel free to contact us!";
		
		
		[lblSender setBackgroundColor:[UIColor clearColor]];
		[lblTime setBackgroundColor:[UIColor clearColor]];
		[lblSubject setBackgroundColor:[UIColor clearColor]];
		[lblContent setBackgroundColor:[UIColor clearColor]];
		
		
		lblSender.font = [UIFont fontWithName:@"Verdana" size: 10.0];
//		[lblSender setTextColor:[UIColor colorWithRed:196 green:188 blue:149 alpha:0.5]];

		lblTime.font = [UIFont fontWithName:@"Verdana" size: 9.0];
		lblSubject.font = [UIFont fontWithName:@"Verdana" size:12];
		lblContent.font = [UIFont fontWithName:@"Verdana" size:9];
		
		[self.contentView addSubview:imgImage];
		[self.contentView addSubview:lblSender];
		[self.contentView addSubview:lblTime];
		[self.contentView addSubview:lblSubject];
		[self.contentView addSubview:lblContent];
	}
    
	return self;
}


- (void)layoutSubviews
{
	[super layoutSubviews];
	CGRect rect = [self.contentView bounds];
	CGRect rect2 = [self.contentView bounds];
	CGSize size = rect.size;
	CGSize size2 = size;
	
	rect.origin.x = 5;
	rect.origin.y = 5;
	size.width = (size.width/4) - 20;
	size.height -= 10;
	rect.size = size;
	
	imgImage.frame = rect;	
	
	
	rect.origin.y -= 6;
	rect.origin.x = 10 + imgImage.frame.size.width;
	size.width = rect2.size.width - size.width - 40;
	size.height = 25;
	rect.size = size;	
	
	lblSender.frame = rect;
	rect.origin.y += 4;
	rect.origin.x = rect2.size.width - 40;
	rect.size.height = 20;
	rect.size.width = 30;
	lblTime.frame = rect;
	
	rect.origin.y += 10;
	rect.size.height = 30;
	rect.size.width = rect2.size.width - 100;
	rect.origin.x = 10 + imgImage.frame.size.width;
	lblSubject.frame = rect;
	
	
	rect.origin.y += 10;
	rect.size.height = 60;
	rect.size.width = rect2.size.width - 100;
	rect.origin.x = 10 + imgImage.frame.size.width;
	lblContent.frame = rect;
}


		 
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)dealloc {
    [super dealloc];
}


@end
